package com.bw.result;

import lombok.Data;

/**
 * @program: search-house
 * @ClassName ResultVo
 * @description:
 * @author:
 * @create: 2023-11-10 15:10
 * @Version 1.0
 **/
@Data
public class ResultVo {

    private int code;

    private String message;

    private boolean result;

    private Object data;

    private ResultVo(){

    }

    public static ResultVo SUCCESS(){
        ResultVo resultVo = new ResultVo();
        resultVo.setCode(ResponseState.SUCCESS.getCode());
        resultVo.setResult(true);

        return resultVo;
    }

    public static ResultVo SUCCESS(Object data){
        ResultVo resultVo = new ResultVo();
        resultVo.setCode(ResponseState.SUCCESS.getCode());
        resultVo.setResult(true);
        resultVo.setData(data);

        return resultVo;
    }

    public static ResultVo FAILED(ResponseState responseState){
        ResultVo resultVo = new ResultVo();
        resultVo.setCode(responseState.getCode());
        resultVo.setResult(false);
        resultVo.setMessage(responseState.getMessage());

        return resultVo;
    }
}
